home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-26 | 2.0 KB | 57 lines | [TEXT/AIFC] |
- /*
- * print selection.p: Print Selection Command.
- *
- * Copyright, © 1992 Advanced A. I. Systems, Inc.
- * All rights reserved.
- * This file may not be copied or distributed without the
- * written permission of Advanced A. I. Systems, Inc.
- *
- This file illustrates making a print selection menu command.
- It uses the functions defined in ::Environment:printer.p.
-
- Here, by using the modifier_keys function, we make this an option to the
- print window command by checking for the shift key (or any other key you
- choose).
-
- However, Prolog cannot have a different name displayed when the shift key is
- depressed and the menu is selected.
-
- You can also make another menu command:
- :- add_menu_command(file_menu, print_selection, "Print Selection…",
- print_selection(active_window)).
-
- You will need to define print_selection/1, Also, you should also modify
- activate and deactivate for text_entry and text_entry_window
- to highlight this the same as open_selection is highlighted.
-
- */
-
- /*
- * New version that checks for the shift key for selection printing.
- * See warning above about menu command not being able to
- * display this command change when selected by the mouse.
- * It is not possible with Prolog to have a menu item appear differently when
- * the shift key is or is not depressed.
- */
- :- no_style_check different_file.
-
- text_entry_window <- print_window(TEW) :-
- active_object(TEW, TextEntry),
- get_font(TextEntry, FontName, FontSize),
- create(io_stream, Input ,TextEntry, read),
- get_text_pos(TextEntry, FromLn, FromPos, ToLn, ToPos),
- (modifier_keys(shift),(FromLn \= ToLn ; FromPos \= ToPos) ->
- true
- ; fseek(Input, 0) /* Only do this when printing the whole window */
- ),
- print_input_stream(Input, FontName, FontSize).
-
- /*
- * We do not need to define the shift-option-p key command.
- * The menu key command will work with shift-option-p.
- */
- :- error(2, "The Print Selection shift option
- has been successfully installed.
- You can now hold the shift key down while
- selecting Print Window to do Print Selection.", _, _, _, _, _, _, _).
-